import uiautomator2 as u2
import schedule
import random
import time



def sign(d):
    print(d)
    d.screen_on()
    d.unlock()
    d.app_start("com.newcapec.mobile.ncp")
    d.xpath('//*[@resource-id="com.newcapec.mobile.ncp:id/home_subapp"]/android.widget.LinearLayout[3]').click()
    d.xpath('//*[@content-desc="早间提交温度时，午间温度请先填“0”"]').set_text("0")
    d(scrollable=True).scroll.to(description="提交信息")
    d.xpath('//*[@content-desc="提交信息"]').click()
    d.xpath('//*[@content-desc="提交信息"]').click()
    d.xpath('//*[@content-desc="返回"]').click()
    d.press("home")
def start_schedule():
    schedule.every().day.at("04:03").do(sign)
    while True:
        schedule.run_pending()
        time.sleep(1)
